package com.job.GaoYuXuan.Homework0711;

import java.util.Objects;

/**
 * @author 盖
 * @version 1.0
 * @since 2022-07-11 21:42:13
 */
public class Computer {
    private String name;
    private Double price;
    private Double weight;
    private int mount;
    private String color;

    public Computer(String name, Double price, Double weight, int mount, String color) {
        this.name = name;
        this.price = price;
        this.weight = weight;
        this.mount = mount;
        this.color = color;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Computer computer = (Computer) o;

        if (mount != computer.mount) return false;
        if (name != null ? !name.equals(computer.name) : computer.name != null) return false;
        if (price != null ? !price.equals(computer.price) : computer.price != null) return false;
        if (weight != null ? !weight.equals(computer.weight) : computer.weight != null) return false;
        return color != null ? color.equals(computer.color) : computer.color == null;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (weight != null ? weight.hashCode() : 0);
        result = 31 * result + mount;
        result = 31 * result + (color != null ? color.hashCode() : 0);
        return result;
    }
    //    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Computer computer = (Computer) o;
//        return mount == computer.mount &&
//                Objects.equals(name, computer.name) &&
//                Objects.equals(price, computer.price) &&
//                Objects.equals(weight, computer.weight) &&
//                Objects.equals(color, computer.color);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(name, price, weight, mount, color);
//    }


    @Override
    public String toString() {
        return "Computer{" +
                "name='" + name + '\'' +
                ", price=" + price +
                ", weight=" + weight +
                ", mount=" + mount +
                ", color='" + color + '\'' +
                '}';
    }
}